import axios from 'axios';
// let base = 'https://www.adrenmai.com/api';
let base = '/admin';
import qs from 'qs';
//别名命名规则：模块+操作，常用操作：list(列表),info(详情),update(更新),destroy(删除),active(激活/启用),forbid(锁定/禁用)
//组件命名规则：一个导航一个目录，导航下的子菜单一个菜单一个文件
//系统登陆
export const UserLogin = params => { return axios.post(`${base}/login`, qs.stringify(params)).then(res => res.data); };
export const UserLogout = params => { return axios.get(`${base}/logout`, params).then(res => res.data); };
export const Captcha = params => { return axios.get(`${base}/captcha`, params).then(res => res.data); };
//管理人员
export const ManageList = params => { return axios.get(`${base}/manage`, params).then(res => res.data); };
export const ManageInfo = params => { return axios.get(`${base}/manage/info`, params).then(res => res.data); };
export const ManageDestory = params => { return axios.get(`${base}/manage/destroy`, params).then(res => res.data); };
export const ManageUpdate = params => { return axios.post(`${base}/manage/update`, qs.stringify(params)).then(res => res.data); };
export const ManageAll  = params => { return axios.get(`${base}/manage/all`, params).then(res => res.data); };
//角色
export const RoleList = params => { return axios.get(`${base}/role`, params).then(res => res.data); };
export const RoleDestory = params => { return axios.get(`${base}/role/destroy`, params).then(res => res.data); };
export const RoleUpdate = params => { return axios.post(`${base}/role/update`, qs.stringify(params)).then(res => res.data); };
export const RoleAccess = params => { return axios.get(`${base}/role/access`, params).then(res => res.data); };
export const RoleAccessUpdate = params => { return axios.post(`${base}/role/access/update`, qs.stringify(params)).then(res => res.data); };
export const RoleAll  = params => { return axios.get(`${base}/role/all`, params).then(res => res.data); };
//分类管理
export const CategoryList  = params => { return axios.get(`${base}/category`, params).then(res => res.data); };
export const CategoryUpdate = params => { return axios.post(`${base}/category/update`, qs.stringify(params)).then(res => res.data); };
export const CategoryDestory  = params => { return axios.delete(`${base}/category/destory`, params).then(res => res.data); };
//背景图片
export const BackList  = params => { return axios.get(`${base}/back`, params).then(res => res.data); };
export const BackUpdate  = params => { return axios.post(`${base}/back/update`, qs.stringify(params)).then(res => res.data); };
export const BackDestory  = params => { return axios.delete(`${base}/back/destory`, params).then(res => res.data); };
export const BackAll  = params => { return axios.get(`${base}/back/all`, params).then(res => res.data); };
//文章管理
export const ArticleList  = params => { return axios.get(`${base}/article`, params).then(res => res.data); };
export const ArticleInfo  = params => { return axios.get(`${base}/article/info`, params).then(res => res.data); };
export const ArticleUpdate  = params => { return axios.post(`${base}/article/update`, qs.stringify(params)).then(res => res.data); };
export const ArticleDestory = params => { return axios.delete(`${base}/article/destory`, params).then(res => res.data); };
export const ArticlePush = params => { return axios.post(`${base}/article/push`, qs.stringify(params)).then(res => res.data); };
export const ArticleDestoryAll = params => { return axios.delete(`${base}/article/destory_all`, params).then(res => res.data); };
//会员管理
export const UserList = params => { return axios.get(`${base}/user`, params).then(res => res.data); };

//模板消息
export const MessageList = params => { return axios.get(`${base}/message`, params).then(res => res.data); };
export const MessageUpdate= params => { return axios.post(`${base}/message/update`, qs.stringify(params)).then(res => res.data); };
export const MessagePush= params => { return axios.post(`${base}/message/push`, qs.stringify(params)).then(res => res.data); };
export const MessageRecord = params => { return axios.get(`${base}/message/record`, params).then(res => res.data); };
export const reToken = params => { return axios.get(`${base}/message/token`, params).then(res => res.data); };  //重置token
//首页
export const IndexCount = params => { return axios.get(`${base}/`, params).then(res => res.data); };
//配置信息(公众号动态url)
export const Config = params => { return axios.get(`${base}/config`, params).then(res => res.data); }; //获取配置信息
export const ConfigUpdate = params => { return axios.post(`${base}/config/update`,  qs.stringify(params)).then(res => res.data); }; //更新配置信息

